package br.ufes.ceunes.poo.view;

import br.ufes.ceunes.poo.view.cadastros.CadastroCliente;
import br.ufes.ceunes.poo.view.cadastros.CadastroFornecedor;
import br.ufes.ceunes.poo.view.cadastros.CadastroPedido;
import br.ufes.ceunes.poo.view.cadastros.CadastroProduto;
import br.ufes.ceunes.poo.view.consultas.Clientes;
import br.ufes.ceunes.poo.view.consultas.Fornecedores;
import br.ufes.ceunes.poo.view.consultas.PedidosAbertos;
import br.ufes.ceunes.poo.view.consultas.Produtos;
import java.awt.EventQueue;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;

public class Principal extends JFrame {

    //String url = System.getProperty("user.dir") + "\icons\";
    public Principal() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        bPedidos = new JButton();
        bClientes = new JButton();
        bPedidosAbertos = new javax.swing.JButton();
        mbPrincipal = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        miCadClientes = new javax.swing.JMenuItem();
        miCadProdutos = new javax.swing.JMenuItem();
        miCadFornecedor = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        miConsultaClientes = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        bPedidos.setText("Vender");
        bPedidos.setIcon(new ImageIcon(getClass().getResource("/icons/shopping_cart.png")));
        bPedidos.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        bPedidos.setName(""); // NOI18N
        bPedidos.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        bPedidos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bPedidosActionPerformed(evt);
            }
        });

        bClientes.setText("Clientes");
        bClientes.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        bClientes.setIcon(new ImageIcon(getClass().getResource("/icons/customer.png")));
        bClientes.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        bClientes.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        bClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bClientesActionPerformed(evt);
            }
        });

        bPedidosAbertos.setText("Pedidos");
        bPedidosAbertos.setIcon(new ImageIcon(getClass().getResource("/icons/shopping-icon.png")));
        bPedidosAbertos.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        bPedidosAbertos.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        bPedidosAbertos.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        bPedidosAbertos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bPedidosAbertosActionPerformed(evt);
            }
        });

        jMenu1.setText("Cadastro");

        miCadClientes.setText("Clientes");
        miCadClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miCadClientesActionPerformed(evt);
            }
        });
        jMenu1.add(miCadClientes);

        miCadProdutos.setText("Produto");
        miCadProdutos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miCadProdutosActionPerformed(evt);
            }
        });
        jMenu1.add(miCadProdutos);

        miCadFornecedor.setText("Fornecedor");
        miCadFornecedor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miCadFornecedorActionPerformed(evt);
            }
        });
        jMenu1.add(miCadFornecedor);

        mbPrincipal.add(jMenu1);

        jMenu2.setText("Consultas");

        miConsultaClientes.setText("Clientes");
        miConsultaClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miConsultaClientesActionPerformed(evt);
            }
        });
        jMenu2.add(miConsultaClientes);

        jMenuItem1.setText("Produto");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem1);

        jMenuItem2.setText("Fornecedor");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem2);

        mbPrincipal.add(jMenu2);

        setJMenuBar(mbPrincipal);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(bClientes)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(bPedidos)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(bPedidosAbertos)
                .addGap(0, 27, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(bPedidosAbertos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(bPedidos, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(bClientes, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void bClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bClientesActionPerformed
        JFrame cadCliente = new CadastroCliente();
        cadCliente.setVisible(true);
    }//GEN-LAST:event_bClientesActionPerformed

    private void miConsultaClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miConsultaClientesActionPerformed
        JFrame tela = new Clientes();
        tela.setAlwaysOnTop(true);
        tela.setVisible(true);
    }//GEN-LAST:event_miConsultaClientesActionPerformed

    private void bPedidosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bPedidosActionPerformed
        JFrame cadPedido = new CadastroPedido();
        cadPedido.setVisible(true);
    }//GEN-LAST:event_bPedidosActionPerformed

    private void miCadClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miCadClientesActionPerformed
        JFrame cadCliente = new CadastroCliente();
        cadCliente.setVisible(true);
    }//GEN-LAST:event_miCadClientesActionPerformed

    private void miCadProdutosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miCadProdutosActionPerformed
      JFrame cadProdutos = new CadastroProduto();
      cadProdutos.setVisible(true);
    }//GEN-LAST:event_miCadProdutosActionPerformed

    private void miCadFornecedorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miCadFornecedorActionPerformed
       JFrame cadFornecedor = new CadastroFornecedor();
       cadFornecedor.setVisible(true);
    }//GEN-LAST:event_miCadFornecedorActionPerformed

    private void bPedidosAbertosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bPedidosAbertosActionPerformed
        JFrame consultaProdutos = new PedidosAbertos();
        consultaProdutos.setVisible(true);
    }//GEN-LAST:event_bPedidosAbertosActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
JFrame tela = new Produtos();
        tela.setAlwaysOnTop(true);
        tela.setVisible(true);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
JFrame tela = new Fornecedores();
        tela.setAlwaysOnTop(true);
        tela.setVisible(true);
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Principal().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bClientes;
    private javax.swing.JButton bPedidos;
    private javax.swing.JButton bPedidosAbertos;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuBar mbPrincipal;
    private javax.swing.JMenuItem miCadClientes;
    private javax.swing.JMenuItem miCadFornecedor;
    private javax.swing.JMenuItem miCadProdutos;
    private javax.swing.JMenuItem miConsultaClientes;
    // End of variables declaration//GEN-END:variables
}
